package com.crm.service.impl.customerManager;

import com.crm.dao.mapper.customMapper.customerManagerCustomMapper.CustomerStatisticsCustomMapper;
import com.crm.model.vo.customerManager.CustomerFollowVO;
import com.crm.service.customerManager.CustomerStatisticsDbService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @Author renshaorong
 * @Date 2021/04/28 9:25 上午
 */
@Service
public class CustomerStatisticsDbServiceImpl implements CustomerStatisticsDbService {

    @Autowired
    CustomerStatisticsCustomMapper customerStatisticsCustomMapper;

    /**
     * 获取时间列表(用于折线图)//上年1 本年2 本周3 本月4 上月5
     * @param dateUnit
     * @return
     */
    @Override
    public List<String> getTimeList(Integer dateUnit){
        return  customerStatisticsCustomMapper.getTimeList(dateUnit);
    }

    /**
     * 根据客户表中客户状态获取折线图数据（包括意向客户、新单客户、续费客户）
     * @param companyId
     * @param dateUnit
     * @param type
     * @return
     */
    @Override
    public List<Integer> getCustomerByState(String companyId, Integer dateUnit, Integer type) {
        return customerStatisticsCustomMapper.getCustomerByState(companyId,dateUnit,type);
    }

    /**
     * 成交客户
     * @param companyId
     * @param dateUnit
     * @return
     */
    @Override
    public List<Integer> getDealCustomer(String companyId, Integer dateUnit) {
        return customerStatisticsCustomMapper.getDealCustomer(companyId,dateUnit);
    }

    /**
     * 客户商机分层——柱状图
     * @param companyId
     * @return
     */
    @Override
    public List<Integer> getCustomerBusiness(String companyId) {
        return customerStatisticsCustomMapper.getCustomerBusiness(companyId);
    }

    /**
     * 客户跟进意向值
     * @param companyId
     * @param type
     * @param dateUnit
     * @param order
     * @return
     */
    @Override
    public List<CustomerFollowVO> getCustomerFollow(String companyId, Integer type,
                                                    Integer dateUnit, String order) {
        return customerStatisticsCustomMapper.getCustomerFollow(companyId,type,dateUnit,order);
    }

    /**
     * 获取地图数据，客户总数
     * @param type
     * @return
     */
    @Override
    public List<Map<String, Object>> getCustomerNumForMap(Integer type,String companyId) {
        return customerStatisticsCustomMapper.getCustomerNumForMap(type,companyId);
    }

    /**
     * 地图未成交客户
     * @param companyId
     * @return
     */
    @Override
    public List<Map<String, Object>> nonDealNumForMap(String companyId) {
        return customerStatisticsCustomMapper.nonDealNumForMap(companyId);
    }

    /**
     * 有商机的客户数
     * @Author renshaorong
     * @Date 2021/6/3
     * @param companyId
     * @return
     */
    @Override
    public Integer hasOpportunity(String companyId){
        return customerStatisticsCustomMapper.hasOpportunity(companyId);
    }

    /**
     * 客户总数
     * @Author renshaorong
     * @Date 2021/6/3
     * @param companyId
     * @return
     */
    @Override
    public Integer customerNum(String companyId){
        return customerStatisticsCustomMapper.customerNum(companyId);
    }
}
